/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package local.ctl;

import java.sql.SQLException;
import java.util.ArrayList;
import local.Historique;
import local.Historique.Type;
import persistance.DaoHistorique;

/**
 *
 * @author xarckane
 */
public class ctlHisto {
    
    public static Historique getHistorique(){
        return null;
        
    }
    public static ArrayList<Historique> getlist(String serv) throws SQLException{
        return DaoHistorique.getAllByServ(serv);
        
    }public static Historique createHistorique(String serv,String type,String date,int id){ 
        Type types=null;
        if (type.equalsIgnoreCase(Historique.Type.CPU.toString())){
            types=Historique.Type.CPU;
        }
        if (type.equalsIgnoreCase(Historique.Type.MEM.toString())){
            types=Historique.Type.MEM;
        }
        if (type.equalsIgnoreCase(Historique.Type.PROCESS.toString())){
            types=Historique.Type.PROCESS;
        }
        if (types!=null){
            return new Historique(serv, types, date, id);
        }
        return null;
}
    public static Historique getObject(Historique histo) throws SQLException {
           
           
       if (histo.getType().toString().equalsIgnoreCase(Historique.Type.CPU.toString())){
           histo.setObject(ctlCpu.getCpuByRequestId(histo.getId()));
       }
       if (histo.getType().toString().equalsIgnoreCase(Historique.Type.MEM.toString())){
           histo.setObject(ctlMemory.getMemory(histo.getId()));
       }
       if (histo.getType().toString().equalsIgnoreCase(Historique.Type.PROCESS.toString())){
           histo.setObject(ctlProcessus.getProcessus(histo.getId()));
       }
      
        return histo;
      

    }
    public static void clear()throws SQLException{
        DaoHistorique.clear();
    
    }
    

    
    
}
